// @ts-ignore
/* eslint-disable */
import {request} from '@umijs/max';
import {StorageListItem} from './data';

export async function storageList(
    params: {
        // query
        /** 当前的页码 */
        current?: number;
        /** 页面的容量 */
        pageSize?: number;
    },
    options?: { [key: string]: any },
) {
    return request<{
        data: StorageListItem[];
        /** 列表的内容总数 */
        total?: number;
        success?: boolean;
    }>('/api/storage/list', {
        method: 'GET',
        params: {
            ...params,
        },
        ...(options || {}),
    });
}

export async function storageSelectList(
    params: {
        name?: string;
    },
    options?: { [key: string]: any },
) {
    return request<{
        data: StorageListItem[];
        /** 列表的内容总数 */
        total?: number;
        success?: boolean;
    }>('/api/storage/selectList', {
        method: 'GET',
        params: {
            ...params,
        },
        ...(options || {}),
    });
}


export async function storageEdit(data: { [key: string]: any }, options?: { [key: string]: any }) {
    return request<StorageListItem>('/api/storage/edit', {
        data,
        method: 'POST',
        ...(options || {}),
    });
}

export async function storageAdd(data: { [key: string]: any }, options?: { [key: string]: any }) {
    return request<StorageListItem>('/api/storage/add', {
        data,
        method: 'POST',
        ...(options || {}),
    });
}

export async function storageDelete(data: { storageIds: string[] }, options?: { [key: string]: any }) {
    return request<Record<string, any>>('/api/storage/delete', {
        data,
        method: 'DELETE',
        ...(options || {}),
    });
}
